
#include <DHTesp.h>

DHTesp dht;

void dht_init(){  
   dht.setup(2, DHTesp::DHT11); 
}

struct dht_data{
  float temp;
  float humi;
};

dht_data _readDht(){
  dht_data dd;
  delay(dht.getMinimumSamplingPeriod());

  dd.humi = dht.getHumidity();
  dd.temp = dht.getTemperature();  
  
  return dd;
}

String _dhtRead(){
  dht_data dd = _readDht();

  float humidity = dd.humi;
  float temperature = dd.temp;

  Serial.print(dht.getStatusString());
  Serial.print("\t");
  Serial.print(humidity, 1);
  Serial.print("\t\t");
  Serial.print(temperature, 1);
  Serial.print("\t\t");
  Serial.print(dht.toFahrenheit(temperature), 1);
  Serial.print("\t\t");
  Serial.print(dht.computeHeatIndex(temperature, humidity, false), 1);
  Serial.print("\t\t");
  Serial.println(dht.computeHeatIndex(dht.toFahrenheit(temperature), humidity, true), 1);

  //String tt = localTime();
  
//  sprintf(buff,
//          tt+",%f,%f\n",
//          temperature,
//          humidity );

  String rets =   String(temperature) +"%2C" + String(humidity);
  String ret =   String(temperature) +"," + String(humidity)+ "\n"; 

  return ret;
}